package com.wjm.shootgame.shoot;

import com.wjm.shootgame.shoot.img.Images;

import java.awt.image.BufferedImage;

public class Hero extends FlyingObject{
    public int life;//生命值
    public int fire;//活力值

    //构造方法初始化
    public Hero(){
        this.width=130;
        this.height=105;
        this.x=100;
        this.y=300;
        this.fire=1;
        this.life=3;
    }


    //用于输出初始化的值
    @Override
    public String toString() {
        return "Hero{" +
                "life=" + life +
                ", fire=" + fire +
                ", width=" + width +
                ", height=" + height +
                ", x=" + x +
                ", y=" + y +
                '}';
    }


    //用来确定获取heros数组图片的下标
    int index = 0;
    @Override
    public BufferedImage getimage() {
        BufferedImage[] heros = Images.heroImage;
        //使获取的图片来回切换，于2取余一直是0，1切换
        return heros[index++ %2];
    }
}
